package 简单工厂模式;

import java.lang.reflect.Constructor;

public class CoffeeFactory {
    public AbstractObject createCoffe(Class<? extends AbstractObject> clazz) throws Exception {
        Constructor<? extends AbstractObject> declaredConstructor = clazz.getDeclaredConstructor();
        declaredConstructor.setAccessible(true);
        AbstractObject abstractObject = declaredConstructor.newInstance();
        return abstractObject;
    }
}
